package com.zhengxing.jienci.content.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhengxing.jienci.common.pojo.Comment;
import com.zhengxing.jienci.common.pojo.CustomizePage;
import com.zhengxing.jienci.common.support.SimpleResponse;
import com.zhengxing.jienci.content.service.CommentService;

@RestController
@RequestMapping("/comment")
public class CommentController {
	
	@Autowired
	private CommentService commentService;
	
	/**
	 * 
	 * @author yyh
	 * @Title: save
	 * @Description: 评论添加
	 * @param @param comment
	 * @param @return
	 * @return SimpleResponse
	 * @throws
	 */
	@PostMapping("/save")
	public SimpleResponse save(@RequestBody Comment comment) {
		return commentService.save(comment);
	}
	
	@GetMapping
	public Page<Comment> list(CustomizePage page, Comment comment){
		return commentService.listForPage(page, comment);
	}
	
	/**
	 * 
	 * @author yyh
	 * @Title: giveOrCancelGood
	 * @Description: 点赞或取消点赞
	 * @param @param id
	 * @param @return
	 * @return SimpleResponse
	 * @throws
	 */
	@PostMapping("/giveOrCancelGood/{id}")
	public SimpleResponse giveOrCancelGood(@PathVariable String id) {
		return commentService.giveOrCancelGood(id);
	}
	
	/**
	 * 
	 * @author yyh
	 * @Title: isGood 
	 * @Description: 
	 * @param @param id
	 * @param @return
	 * @return SimpleResponse
	 * @throws
	 */
	@GetMapping("/isGood/{id}")
	public SimpleResponse isGood(@PathVariable String id) {
		return commentService.isGood(id);
	}
	
}
